package com.yycwxt.modules.admin.core_flows;

import com.yycwxt.domain.Flows;
import com.yycwxt.domain.Shop;
import com.yycwxt.domain.Store;
import com.yycwxt.domain.Subject;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * Created by Mr.Zhang on 2022/8/26 21:27
 */
@Service
@Transactional // 开启事务
public class FlowsService {

    private final FlowsMapper flowsMapper;

    public FlowsService(@Autowired FlowsMapper flowsMapper) {
        this.flowsMapper = flowsMapper;
    }

    // 查询全部
    public List<Flows> selectAll() {
        return flowsMapper.selectAll();
    }

    // 按账期查询全部流水
    public List<Flows> selectAllByAccountDate(Integer accountDate) {
        return flowsMapper.selectAllByAccountDate(accountDate);
    }

    // 查询账期
    public Object[] selectAccountDate() {
        return flowsMapper.selectAccountDte();
    }

    // 根据输入查询全部
    public List<Flows> selectByInput(String input) {
        return flowsMapper.selectByInput(input);
    }

    // 新增流水
    public int add(String orderNumber, Integer accountDate, String shopCode, String storeCode,
                   String subjectCode, Integer subjectDirection, BigDecimal cost, String remark) {
        return flowsMapper.insertFlows(orderNumber, accountDate, shopCode, storeCode, subjectCode,
                subjectDirection, cost, remark);
    }


    // 查询科目名称
    public List<Subject> selectSubjectName() {
        return flowsMapper.selectSubjectName();
    }

    // 查询店铺名称
    public List<Shop> selectShopName() {
        return flowsMapper.selectShopName();
    }

    // 查询仓库名称
    public List<Store> selectStoreName() {
        return flowsMapper.selectStoreName();
    }

}
